<!DOCTYPE HTML>
<html>
<head>
<title>comment</title>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css"
	media="all">
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">

<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<link rel="stylesheet" href="css/flexslider.css" type="text/css"
	media="screen" />
<link href="css/megamenu.css" rel="stylesheet" type="text/css"
	media="all" />
<script type="text/javascript" src="js/megamenu.js"></script>

<script src="js/menu_jquery.js"></script>
<link rel="stylesheet" href="css/etalage.css">
<script src="js/jquery.easydropdown.js"></script>
<script src="js/jquery.etalage.min.js"></script>

<script type="text/javascript" src="js/jquery.jscrollpane.min.js"></script>
<link rel="stylesheet" href="layui/css/layui.css">
</head>
<body>
	<!-- header -->
	<div style="height: 100px;">
		<div style="position: fixed; width: 100%; z-index: 999;">
			<div class="header">
				<div class="top_bg" style="background-color: white;">
					<div class="container">
						<div class="header_top">
							<div class="logo">
								<a href="index.html"><img src="images/logo.png" alt="" />蜗牛影院</a>
							</div>
							<div class="top_right" style="margin-top: 0">
								<div id="userMessage" style="line-height: 45px;display: none;">
								<!-- <a href="info.html"><img alt="" src="images/aimg.jpg" height="40px" style="border-radius: 50%;" id="uimg">&nbsp<span style="color:black;" id="uname">1823342352323</span></a> -->
							</div>
							<ul id="userLogin" style="line-height: 45px;display: none;">
									<li><a href="registration.html"><button type="button"
												class="btn btn-info">注册</button></a></li>|
									<li class="login">
										<div id="loginContainer">
											<a href="#" id="loginButton"><button type="button"
													class="btn btn-info">登陆</button></a>
											<div id="loginBox">
												<form id="loginForm">
													<fieldset id="body">
														<fieldset>
															<label for="email">账号</label> <input type="text"
																name="email" id="email">
														</fieldset>
														<fieldset>
															<label for="password">密码</label> <input type="password"
																name="password" id="password">
														</fieldset>
														<input type="submit" id="login" value="登陆"> <label
															for="checkbox"><input type="checkbox"
															id="checkbox"> <i>记住我</i></label>
													</fieldset>
													<span><a href="#">密码忘记了?</a></span>
												</form>
											</div>
										</div>
									</li>
								</ul>
							</div>
							<div class="clearfix"></div>
						</div>
					</div>
				</div>
			</div>
			<div class="head-bann">
				<div class="container">
					<div class="head-nav">
						<span class="menu"> </span>
						<ul class="megamenu skyblue">
							<li><a class="color1" href="index.html">首页</a></li>
							<li class="grid"><a class="color2" href="movies.html">影片</a></li>
							<li><a class="color4" href="cinema.html?mid=1">影院</a></li>
							<li><a class="color5" href="comment.html">评论</a></li>
							<div class="clearfix"></div>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- script-for-nav -->
	<script>
		$("span.menu").click(function() {
			$(".head-nav ul").slideToggle(300, function() {
				// Animation complete.
			});
		});
	</script>
	<!-- script-for-nav -->

	<div class="banner1">
		<div class="container"></div>
	</div>
	<!-- header -->
	<div class="container">
		<div class="women_main">
	<div id="allInf">
		<blockquote class="layui-elem-quote"
			style="background-color: white; width: 650px; font-size: 18px; display: inline">
			所有评价</blockquote>
		<div class="site-demo-button" id="layerDemo" style="margin-bottom: 0;">
		<button data-method="notice" type="button"class="layui-btn layui-btn-danger  layui-btn-sm"style="margin-left: 40%"><i class="layui-icon"></i>写评论</button>
		</div>
	</div>
		</div>
	</div>


	<script src="layui/layui.all.js"></script>
	<script src="layui/jquery.min.js"></script>
	<script>
			var o;
			$(function(){
				getUser();
				var com="";
				$.ajax({
					url:"/comment/allComment",
					type:"get",
					success:function(data){
						o=data;
						var con="";
						for(var i=0;i<data.length;i++){
							con+='<div style="width: 700px;height: 140px;">'
							+'<div style="width: 60px;height: 100px;float: left;margin-top: 12px;">'
							+'<img src="'+data[i].uimg+'" style="width: 58px;" />'
							+'</div>'
							+'<div style="width: 635px;height: 35px;float: left;">'
							+'<div style="font-size: 16px;line-height: 45px;display: inline;margin-left: 20px;">'+data[i].account+'</div>'
							+'<span class="layui-badge layui-bg-blue">购</span>'
							+'</div>'
							+'<div style="width: 635px;height: 35px;float: left;">'
							+'<div style="font-size: 16px;line-height: 10px;display: inline;margin-left: 20px;">'+data[i].adate+'<div id="star'+i+'" style="margin-bottom: 5px;margin-left: 10px;"></div></div>	'
							+'</div>'
							+'<div style="width: 600px;height: 60px;float: left;border-bottom: #B2B2B2 1px solid;margin-left: 20px;margin-top: 5px;color: #8D8D8D;font-size: 14px;">'+data[i].acomment+'</div>'
						}
						$("#allInf").append(con);
						qwe(o);
					}
				})
			});
			
			function qwe(o){
				layui.use(['rate'], function() {
					var rate = layui.rate;
					for(var i=0;i<o.length;i++){
						  rate.render({
							   elem: '#star'+i
							    ,value: o[i].agrade //初始值
							    ,half: true //开启半星
							    ,readonly:true
						 })
					}
				});
			}
			function getUser() {
				$.ajax({
					url:"user/getUser",
					type:"get",
					success:function(data){
						if(data!=""){
							$("#userLogin").css("display","none");
							$("#userMessage").css("display","block");
							var content = '<a href="info.html">'
								+'<img alt="" src="'+data.uimg+'" height="40px" style="border-radius: 50%;">&nbsp'
								+'<span style="color:black;" id="uname">'+data.uname+'</span>&nbsp&nbsp'
								+'</a>'
								+'<button type="button" class="btn btn-info" onclick="logout()" style="">注销</button>';
							$("#userMessage").html(content);
						}else{
							$("#userLogin").css("display","block");
							$("#userMessage").css("display","none");
						}
					}
				});
			}
			function logout(){
				$.ajax({
					url:"user/logout",
					type:"get",
					success:function(data){
						getUser();
					}
				});
			}
			function getUser() {
				$.ajax({
					url:"user/getUser",
					type:"get",
					success:function(data){
						if(data!=""){
							$("#userLogin").css("display","none");
							$("#userMessage").css("display","block");
							var content = '<a href="info.html">'
								+'<img alt="" src="'+data.uimg+'" height="40px" style="border-radius: 50%;">&nbsp'
								+'<span style="color:black;" id="uname">'+data.uname+'</span>&nbsp&nbsp'
								+'</a>'
								+'<button type="button" class="btn btn-info" onclick="logout()" style="">注销</button>';
							$("#userMessage").html(content);
						}else{
							$("#userLogin").css("display","block");
							$("#userMessage").css("display","none");
						}
					}
				});
			}
			function logout(){
				$.ajax({
					url:"user/logout",
					type:"get",
					success:function(data){
						getUser();
					}
				});
			}
			
		</script>

	<!-- 弹出层 -->
	<script>
			layui
					.use(
							'layer',
							function() { //独立版的layer无需执行这一句
								var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句

								//触发事件
								var active = {
									setTop : function() {
										var that = this;
										//多窗口模式，层叠置顶
										layer
												.open({
													type : 2 //此处以iframe举例
													,
													title : '当你选择该窗体时，即会在最顶端',
													area : [ '600px', '400px' ],
													shade : 0,
													maxmin : true,
													offset : [ //为了演示，随机坐标
															Math.random()
																	* ($(window)
																			.height() - 300),
															Math.random()
																	* ($(window)
																			.width() - 390) ],
													content : '//layer.layui.com/test/settop.html',
													btn : [ '继续弹出', '全部关闭' ] //只是为了演示
													,
													yes : function() {
														$(that).click();
													},
													btn2 : function() {
														layer.closeAll();
													}

													,
													zIndex : layer.zIndex //重点1
													,
													success : function(layero) {
														layer.setTop(layero); //重点2
													}
												});
									},
									notice : function() { //新增按钮弹出层
										//示范一个公告层
										layer
												.open({
													type : 2,
													title : false //不显示标题栏
													,
													closeBtn : true,
													area : [ '600px', '300px' ],
													shade : 0.8,
													shadeClose : true,
													anim : 4,
													id : 'LAY_layuipro' //设定一个id，防止重复弹出
													/* ,btn: ['新增', '取消'] */
													,
													btnAlign : 'c',
													moveType : 1 //拖拽模式，0或者1
													,
													content : 'addComment.html',
													success : function(layero,index) {
														
													},
													end: function(index, layero){ 
														window.location.reload();
														}  
													
												});
									},
									offset : function(othis) {
										var type = othis.data('type'), text = othis
												.text();

										layer
												.open({
													type : 1,
													offset : type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
													,
													id : 'layerDemo' + type //防止重复弹出
													,
													content : '<div style="padding: 20px 100px;">'
															+ text + '</div>',
													btn : '关闭全部',
													btnAlign : 'c' //按钮居中
													,
													shade : 0 //不显示遮罩
													,
													yes : function() {
														layer.closeAll();
													}
												});
									}
								};

								$('#layerDemo .layui-btn').on(
										'click',
										function() {
											var othis = $(this), method = othis
													.data('method');
											active[method] ? active[method]
													.call(this, othis) : '';
										});

							});
			
		</script>
</body>
</html>
